#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QSystemTrayIcon>
#include <QTreeWidgetItem>
#include <QMainWindow>
#include <QMenu>

#include "chattabbedwidget.h"
#include "settingswidget.h"
#include "xstatuswidget.h"
#include "searchwidget.h"

#include "icybuddy.h"


namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow {
    Q_OBJECT

    public:
        MainWindow(QWidget *parent = 0, IcySettings *fSettings = 0,
                   IcyBuddies *fBuddies = 0);
        ~MainWindow();

        void setAccount(const IcyAccount &fAccount);

    protected:
        void changeEvent(QEvent *e);

    private:
        Ui::MainWindow *ui;
        SettingsWidget *settingsWidget;
        SearchWidget *searchWidget;
        ChatTabbedWidget *tabbedWidget;

        IcyAccount *account;
        IcySettings *settings;
        IcyBuddies *buddies;

        QList<QTreeWidgetItem *> treeItems;

        QMenu *mainMenu, *statusMenu, *pStatusMenu, *xStatusMenu, *contactMenu;
        QSystemTrayIcon *trayIcon;
        QAction *actionOptions,
                *actionInfo,
                *actionSearch,
                *actionAbout,
                *actionClose,
                *actionXStatus,
                *actionStatusOnline,
                *actionStatusOffline,
                *actionStatusDND,
                *actionStatusBusy,
                *actionStatusAway,
                *actionStatusAngry,
                *actionStatusDepression,
                *actionStatusFFC,
                *actionOpenChat;

        void setupMenus();
        void setupWindow();
        void refreshBuddies();
        _fastcall QIcon getIcon(const QString &sIcon);

    private slots:
        void on_closeBtn_clicked();

        void onSettingsClicked();
        void onSearchClicked();
        void onOpenChatClicked();
        void onContextMenuRequested(QPoint point);

        void onTrayClicked(QSystemTrayIcon::ActivationReason reason);
};

#endif // MAINWINDOW_H
